<template>
  <header class="header">
        <h1>todos</h1>
        <input 
        class="new-todo" 
        placeholder="What needs to be done?" 
        autofocus
        v-model.trim="name"
        @keyup.enter="add"
        >
      </header>
</template>

<script>
export default {
  data() {
    return {
      name:''
      
    }
  },
 methods: {
   add()  {
       if(this.name==='') {
         return alert('请输入内容')
       }
       this.$emit('add',this.name)
       this.name=''
   }
 }
}
</script>

<style>

</style>